<?php
declare (strict_types=1);

namespace app\course\service\config\admin;

use app\admin\logic\system\Config as SystemConfig;
use eduline\admin\libs\pageform\FormItem;
use eduline\admin\page\PageForm;
use think\Response;

/**
 * Class Config
 *
 * @package app\course\service\config
 */
class Config
{
    /**
     * 课程评论与笔记
     * Author: Martinsun <syh@sunyonghong.com>
     * Date: 2021/9/3
     *
     * @return Response
     */
    public function commentnote(): Response
    {
        // 字段定义
        $fields = [
            'comment'    => FormItem::make('SlideSwitch')->title('课程评论')->activeValue(1)->inactiveValue(0),
            'note'       => FormItem::make('SlideSwitch')->title('课程笔记')->activeValue(1)->inactiveValue(0),
            'exam'       => FormItem::make('SlideSwitch')->title('课程考试')->activeValue(1)->inactiveValue(0),
            'courseware' => FormItem::make('SlideSwitch')->title('课程课件')->activeValue(1)->inactiveValue(0),
        ];

        $form          = new PageForm();
        $form->pageKey = $fields;
        $form->withSystemConfig();
        $key             = 'course.config.comment_note';
        $config          = SystemConfig::get($key, [], request()->mhm_id);
        $config['__key'] = $key;
        $form->datas     = $config;

        return $form->send();
    }
}
